home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Singles Flirt Up Your Life! (German)
/
Singles Flirt Up Your Life.iso
/
data1.cab
/
Statemachine
/
cameraChar.lua
< prev
next >
Wrap
Text File
|
2004-01-29
|
9KB
|
331 lines
-- camera character state machine
beginStateMachine()
onEnter(function(msg)
local camera = getStateObjectFromID(msg.sender);
storeStateObject("camera", camera);
if (camera) then
-- -- camera does exist
-- if (getParent().isOneActionPointLocked(camera)) then
-- -- action point is locked
-- getParent().setEmoticon(EMOTICON_CANNOT, EMOTICON_DELAY);
-- sendMsg("emoThink", getParent().walkSO);
-- exitStateMachine();
-- else
-- getParent().lockActionPoints(camera);
-- end
else
-- camera does not exist anymore
getParent().setEmoticon(EMOTICON_CANNOT, EMOTICON_DELAY);
sendMsg("emoThink", getParent().walkSO);
exitStateMachine();
end
freeHands(getParent());
end )
onExit(function(msg)
-- local camera = retrieveStateObject("camera");
-- if (camera) then
-- getParent().unlockActionPoints(camera);
-- getParent().stopAllActivities(camera);
-- removeStateObject("camera");
-- end
print("----- cameraChar onExit 1 " .. getParent().getCharacterName());
unlockAll("camera");
print("----- cameraChar onExit 2 " .. getParent().getCharacterName());
local partner = retrieveStateObject("partner");
if (partner) then
getParent().unlockActionPoints(partner.getParent());
getParent().stopAllActivities(partner.getParent());
removeStateObject("partner");
end;
end )
-- state("waitForPartner")
--
-- onEnter(function(msg)
-- sendDelayedMsgThis("stopWaiting", 20000);
-- this.actionComplete();
-- end )
--
-- onMsg("stopWaiting", function(msg)
-- local camera = retrieveStateObject("camera");
-- getParent().stopActivity("takePicture", camera);
-- exitStateMachine();
-- end )
--
-- onMsg("partnerReady", function(msg)
-- setState("takePicture");
-- end )
--
--
-- onMsg("queue", function(msg)
-- sendMsgThis("stopWaiting");
-- end )
state("waitForPartner")
onEnter(function(msg)
local camera = getStateObjectFromID(msg.sender);
if (getParent().isActionPointLocked(camera, "use")) then
-- action point is locked
getParent().setEmoticon(EMOTICON_CANNOT, EMOTICON_DELAY);
sendMsg("emoThink", getParent().walkSO);
exitStateMachine();
else
getParent().lockActionPoint(camera, "use");
end
setPose(archize(getParent(),"stand1"));
print("waitForPartner onEnter");
sendDelayedMsgThis("callPartner", 1000);
sendDelayedMsgThis("stopWaiting", 20000);
this.actionComplete();
startAnimation("emoSwingArms");
end )
onMsg("end", function(msg)
startAnimation("emoSwingArms");
end )
onMsg("queue", function(msg)
sendMsgThis("stopWaiting");
end )
onMsg("stopWaiting", function(msg)
exitStateMachine();
end )
onMsg("callPartner", function(msg)
print("callPartner");
if testCancel() then
sendMsgThis("stopWaiting");
return
end
-- get the game object server
local gameObjectServer = getParent().getGameObjectServer();
local partner = getOtherCharacter(getParent());
if (not partner) then
print("waitForPartner: no partner found");
getParent().setEmoticon(EMOTICON_PARTNER, EMOTICON_DELAY);
sendDelayedMsgThis("callPartner", 1000);
return
end
local camera = retrieveStateObject("camera");
local poseActionPointsInSight = getActionPointsInSight(camera, "center", 1.7, camera, {"pose1","pose2","pose3"}, 1.7, partner);
-- local poseActionPoint = partner.getClosestFreeActionPoint(partner, camera, tremoven(poseActionPointsInSight));
local poseActionPoint = partner.getClosestFreeActionPoint(partner, camera, tremoven(poseActionPointsInSight), true);
if (not poseActionPoint) then
print("waitForPartner: poseActionPoint not found");
partner.setEmoticon(EMOTICON_CANNOT, EMOTICON_DELAY);
sendDelayedMsgThis("callPartner", 1000);
return
end
-- local wso = partner.walkSO;
-- wso.storeData("actionPointName", poseActionPoint.getName());
--
-- if (not wso.walkToActionPoint(poseActionPoint)) then
-- print("waitForPartner: partner cant reach poseActionPoint");
-- partner.setEmoticon(EMOTICON_NOPATH, EMOTICON_DELAY);
-- sendDelayedMsgThis("callPartner", 1000);
-- return
-- end
--
-- storeStateObject("partner", wso);
--
-- -- create partners state machine contexts
-- local wsoContext = StateMachineContext();
-- wsoContext.storeStateObject("camera", camera);
-- wsoContext.storeStateObject("partner", this);
-- wsoContext.storeData("poseActionPoint", poseActionPoint.getName());
--
-- -- send partner to chair
-- wso.queueStateMachine("cameraChar.pose", camera, wsoContext);
storeStateObject("partner", partner.walkSO);
local wsoContext = StateMachineContext();
wsoContext.storeStateObject("camera", camera);
wsoContext.storeStateObject("partner", this);
wsoContext.storeData("actionPointName", poseActionPoint.getName());
-- queue walk and state change msg for this(passive) character
local passiveMsg = QueuedMessage();
passiveMsg.set(Message.MSG_RESERVED_EnterStateMachine, camera.getUniqueID(), "cameraChar.poseWait", wsoContext);
partner.pushWalkActionPoint("pm_pose", poseActionPoint, false, passiveMsg);
end )
onMsg("partnerReady", function(msg)
print("----- partner of " .. getParent().getCharacterName() .. " is ready -----");
local partner = retrieveStateObject("partner");
setState("takePicture");
sendMsg("partnerReady", partner);
end )
state("takePicture")
onEnter(function(msg)
local camera = retrieveStateObject("camera");
getParent().startActivity("takePicture", camera);
startAnimation("takePictureStart");
sendDelayedMsgThis("clickSound", 900);
sendDelayedMsgThis("testCancel", CANCEL_POLLING_INTERVAL);
end )
onMsg("clickSound", function(msg)
getParent().playSound("cameraShots");
end )
onMsg("stopTakePicture", function(msg)
setState("takePictureStop");
end )
onMsg("testCancel", function(msg)
if testCancel() then
local partner = retrieveStateObject("partner");
sendMsg("stopPose", partner);
sendMsgThis("stopTakePicture");
else
sendDelayedMsgThis("testCancel", CANCEL_POLLING_INTERVAL);
end
end )
onMsg("end", function(msg)
sendDelayedMsgThis("stopTakePicture", 11000);
end )
state("takePictureStop")
onEnter(function(msg)
startAnimation("takePictureStop");
end )
onMsg("end", function(msg)
local camera = retrieveStateObject("camera");
getParent().stopActivity("takePicture", camera);
exitStateMachine();
end )
state("poseWait")
onEnter(function(msg)
print("--poseWait onEnter--- " .. getParent().getCharacterName());
local camera = retrieveStateObject("camera");
local actionPointName = retrieveData("actionPointName");
if (getParent().isActionPointLocked(camera, actionPointName)) then
-- action point is locked
sendMsgThis("stop");
return
else
getParent().lockActionPoint(camera, actionPointName);
end
local partner = retrieveStateObject("partner");
sendDelayedMsgThis("ready", 1000);
sendDelayedMsgThis("stop", 5000);
startAnimation("emoSwingArms");
end )
onMsg("end", function(msg)
startAnimation("emoSwingArms");
end )
onMsg("stop", function(msg)
print("----- " .. getParent().getCharacterName() .. " has stopped waiting ----- ");
getParent().setEmoticon(EMOTICON_CANNOT, EMOTICON_DELAY);
sendMsg("emoThink", getParent().walkSO);
exitStateMachine();
end )
onMsg("ready", function(msg)
print("----- " .. getParent().getCharacterName() .. " is ready ----- cancel: ");
-- send a message to the partner
local partner = retrieveStateObject("partner");
if (testCancel()) then
sendMsgThis("stop");
else
sendMsg("partnerReady", partner);
sendDelayedMsgThis("ready", 1000);
end
end )
onMsg("partnerReady", function(msg)
print("----- partner of " .. getParent().getCharacterName() .. " is ready -----");
local partner = retrieveStateObject("partner");
setState("pose");
sendMsg("partnerReady", partner);
end )
state("pose")
onEnter(function(msg)
print("----- pose onEnter " .. getParent().getCharacterName());
local camera = retrieveStateObject("camera");
getParent().startActivity("pose", camera);
startAnimation("emoFlirt");
sendDelayedMsgThis("testCancel", CANCEL_POLLING_INTERVAL);
end )
onMsg("testCancel", function(msg)
if testCancel() then
local partner = retrieveStateObject("partner");
sendMsg("stopTakePicture", partner);
sendMsgThis("stopPose");
else
sendDelayedMsgThis("testCancel", CANCEL_POLLING_INTERVAL);
end
end )
onMsg("stopPose", function(msg)
local camera = retrieveStateObject("camera");
getParent().stopActivity("pose", camera);
exitStateMachine();
end )
onMsg("end", function(msg)
sendMsgThis("stopPose");
end )
endStateMachine()